package com.iweb.day10;

import java.io.FileInputStream;
import java.io.IOException;

/**
 * @author WuYongheng
 * @date 2021/11/20
 * @description
 */
public class Test1 {
    public static void main(String[] args) {
        FileInputStream fileInputStream = null;
        try {
            String path = "C:\\Users\\Administrator\\Desktop\\aa.txt";
            // 确定要做什么事情, 读取文件的内容
            // 1.创建输入流对象
            fileInputStream = new FileInputStream(path);
            // 2.进行文件的操作
            int read = -1;
//            // ps: 读取到的是字节
//            System.out.println(read);
//            char word = (char)read;
//            System.out.println(word);
            // todo:希望读取到文件里的所有内容
            while (true) {
                read = fileInputStream.read();
                if (read != -1) {
                    break;
                }
                System.out.print((char) read);
            }

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            // 3.释放资源
            try {
                if (fileInputStream != null) {
                    fileInputStream.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

}
